package com.sylar.lelepub;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;

public class LoadingActivity extends Activity{

	Handler mHandler = new Handler(){
		public void handleMessage(Message msg) {
			toMainActivity();
		};
	};
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		
		super.onCreate(savedInstanceState);
		
		ImageView img = new ImageView(getApplicationContext());
		img.setScaleType(ScaleType.FIT_XY);
		img.setImageResource(R.drawable.loading);
		
		setContentView(img);
		
		new Thread(){
			public void run() {
				
				try {
					currentThread().sleep(2000);
					mHandler.sendEmptyMessage(200);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			};
		}.start();
		
	}
	
	
	void toMainActivity(){
		Intent intent = new Intent(this,MainActivity.class);
		startActivity(intent);
		finish();
	}
	
}
